package com.youdianstar.app.entity

import com.youdianstar.app.common.util.StrUtil

/**
 * File: CardEntity
 * Author: 82149 Create: 2021/11/24 12:29
 * Changes (from 2021/11/10)
 * --------------------------------------------------
 * description: 卡数据
 * ---------------------------------------------------
 */
data class CardEntity(
    val id: Int,
    //银行卡有效期：月/年
    val bankExpire: String,
    //银行名称:VISA MASTER
    val bankName: String,
    //卡的类型：debit credit prepaid unknown
    val bankType: String,

    val bankNo: String,
    //银行卡token
    val bankToken: String,
    //customerId
    val customerId: String,
    //是否默认 0：否 1：是
    val defaulted: Boolean,
    //是否过期 0：否 1：是
    val expire: Boolean

){
    fun expireTx():String{
        if (StrUtil.isEmpty(bankExpire))
            return ""
        return if (!bankExpire.contains("/") || bankExpire.length == 5){
            bankExpire
        }else{
            val dateArray = bankExpire.split("/")
            if (dateArray.size==2){
                StrUtil.getCardExp(dateArray[1].toInt(),dateArray[0].toInt())
            }else{
                bankExpire
            }
        }
    }
}